package be.ac.ua.ecampus.uacmat.entity;

import java.sql.SQLException;
import java.util.Collection;
import java.util.HashSet;

import be.ac.ua.ecampus.uacmat.QueryHandler;

public class Packet extends Entity {

	private int fAcademicYear;
	private Collection<Syllabus> fSyllabuses;
	
	public Packet(String id, String description, int academicYear) throws SQLException {
		super("packet", id, description);
		this.fAcademicYear = academicYear;
		this.fSyllabuses = new HashSet<Syllabus>();
	}

	public int getAcademicYear() {
		return fAcademicYear;
	}

	public Collection<Syllabus> getSyllabuses() throws SQLException {
		if (fSyllabuses.isEmpty()) {
			QueryHandler queryHandler = new QueryHandler();
			fSyllabuses = queryHandler.getSyllabusesForPacket(this.fId);
		}
		return fSyllabuses;
	}
	
}
